﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ANLP
{
    public class LexLocation
    {
        public LexLocation(int start, int end)
        {
            this.start = start;
            this.end = end;
        }
        private int start;

        public int Start
        {
            get { return start; }
            set { start = value; }
        }

        private int end;

        public int End
        {
            get { return end; }
            set { end = value; }
        }
    }

    internal class ReverseComparer<T> : IComparer<T>
    {
        private IComparer<T> comparer;
        public ReverseComparer(IComparer<T> comparer)
        {
            this.comparer = comparer;
        }

        #region IComparer<T> Members

        public int Compare(T x, T y)
        {
            return -comparer.Compare(x, y);
        }

        #endregion
    }

    internal class LexLocationComparer : IComparer<LexLocation>
    {
        #region IComparer<LexLocation> Members

        public int Compare(LexLocation x, LexLocation y)
        {
            if (x.Start < y.Start)
            {
                return -1;
            }
            if (x.Start == y.Start)
            {
                if (x.End < y.End)
                    return 1;
                if (x.End == y.End)
                    return 0;
                return -1;
            }
            if (x.Start > y.Start)
            {
                return 1;
            }
            return 0;
        }

        #endregion
    }
}
